package com.toivan.mt.views;

import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.toivan.mt.R;
import com.toivan.mt.adapter.MtCuteClassAdapter;
import java.util.ArrayList;
import java.util.List;

/**
 * 萌图模式选中面板
 */
public class MtCuteClassView extends FrameLayout {
    private RecyclerView cuteRV;
    private List<Integer> classList;


    public MtCuteClassView(@NonNull Context context) {
        super(context);
    }


    public MtCuteClassView(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }


    public MtCuteClassView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }


    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    public MtCuteClassView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }


    public void init() {
        initView();

        initData();
    }


    private void initView() {
        LayoutInflater.from(getContext()).inflate(R.layout.layout_cute, this);

        cuteRV = findViewById(R.id.cute_recyclerview);
        classList = new ArrayList<>();
    }


    private void initData() {
        classList.clear();
        classList.add(R.drawable.icon_class_sticker);
        classList.add(R.drawable.icon_class_expression);
        classList.add(R.drawable.icon_class_mask);
        classList.add(R.drawable.icon_class_atmosphere);
        classList.add(R.drawable.icon_class_watermark);
        classList.add(R.drawable.icon_class_portrait);
        classList.add(R.drawable.icon_green_screen);

        cuteRV.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
        MtCuteClassAdapter adapter = new MtCuteClassAdapter(classList);
        cuteRV.setAdapter(adapter);
    }

}


